#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <vector>

using namespace std;
using LL = long long;
const LL N = 2e5 + 10, M = N * 32;

LL n;
LL son[M][2], cnt[M], idx;
LL res = 1e18 + 10;
bool ok = false;

void add(LL x){
    LL p = 0;
    for(LL i = 30; i >= 0; i --){
        LL u = (x >> i & 1);
        if(!son[p][u]) son[p][u] = ++idx;
        p = son[p][u];
    }
    cnt[p] ++;
}

void dfs(LL p, LL x, LL deepth){
    if(deepth == -1){
        res = min(res, x);
        return;
    }

    if(son[p][1] && son[p][0]){
        LL cur = x + (1ll << deepth);
        dfs(son[p][1], cur, deepth - 1);
        dfs(son[p][0], cur, deepth - 1);
    }else if(son[p][1] && !son[p][0]){
        LL cur = x;
        dfs(son[p][1], cur, deepth - 1);
    }else{
        LL cur = x;
        dfs(son[p][0], cur, deepth - 1);
    }



}

int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> n;
    for(LL i = 1, x; i <= n; i ++){
        cin >> x;
        add(x);
    }

    dfs(0, 0, 30);
    cout << res << '\n';


    return 0;
}